﻿<!DOCTYPE html>

<html class="x-admin-sm">
<head>
    <meta name="viewport" content="width=device-width" />
    <meta charset="UTF-8">
    <title>工序产量统计</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link href="~/js/layui/css/layui.css" rel="stylesheet" />
    <link href="~/X-admin/css/font.css" rel="stylesheet" />
    <link href="~/X-admin/css/xadmin.css" rel="stylesheet" />
    <script src="~/X-admin/js/jquery.min.js"></script>
    <script src="~/X-admin/js/xadmin.js"></script>
    <script src="~/js/framework/sysframework.js"></script>
    <script src="~/js/framework/commonjs.js"></script>
    <script src="~/js/layui/layui.js"></script>

</head>
<body>
    <div class="layui-fluid">
        <div id="bDiv">
        </div>
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body ">
                        <form class="layui-form layui-col-space5" name="qForm" id="qForm">


                            <div class="layui-inline layui-show-xs-block">

                                <input class="layui-input" placeholder="开始日期" autocomplete="off" name="sDate" id="sDate" style="margin-right:15px;">
                            </div>

                            <div class="layui-inline layui-show-xs-block">
                                <input class="layui-input" placeholder="结束日期" name="eDate" id="eDate" autocomplete="off" style="margin-right:15px;">
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <select id="machine" name="machine" lay-search lay-filter="machine">
                                    <option value="">生产机台</option>
                                </select>
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <input class="layui-input" placeholder="关联计划" name="plCode" id="plCode"  style="margin-right:15px;">
                            </div>
                            <input type="hidden" name="gxCode" id="gxCode" />

                        </form>
                    </div>

                    <div class="layui-card-body" id="layui-table-main">
                        <table class="layui-hide" id="list" lay-filter="list"></table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>

</html>

<script>
    var barCodes = "";
    var currPage = 1;//首先默认值为1，防止出错
    function loadData() {
        layui.use('table', function () {
            var conditon = JSON.stringify(FormToJson("qForm"));

            var dUrl = "../Summary/GetDataList?dataType=gxtp&condition=" + conditon;
            var table = layui.table;
            table.render({
                elem: '#list'
                , height: 'full-140'   //固定高度-即固定表头固定第一行首行
                , cols: [[ //标题栏
                    { field: 'hDate', align: 'center', title: '日 期', width: '16%',totalRowText: '合计' }
                    , { field: 'proCode', align: 'center', title: '存货编码', width: '12%' }
                    , { field: 'proName', align: 'center', title: '存货名称', width: '22%' }
                    , { field: 'spec', align: 'center', title: '规 格', width: '14%' }
                    , { field: 'number', align: 'center', title: '数 量', width: '10%', totalRow: true }
                    , { field: 'machineName', align: 'center', title: '生产机台', width: '12%' }
                    , { field: 'planCode', align: 'center', title: '关联计划', width: '12%' }
                ]], done: function (res, curr, count) {
                  //  $("[data-field='id']").css('display', 'none');//隐藏列
                    currPage = curr;
                    TablePowerHide();
                }
                , url: dUrl
                , skin: 'row' //表格风格
                , even: true
                , page: { layout: ['count', 'prev', 'page', 'next', 'skip', 'limit'], groups: 1, first: false, last: false }
                , page: false //是否显示分页
                , limits: [20, 35, 50]
                , totalRow: true //开启合并行
                , limit: 20 //每页默认显示的数量
                , id: "tData"
            });
 



        });
    }

    var webCode = "";
    $(function () {
        webCode = getUrlVariable("menuCode");
        BannerData(webCode, "bDiv");
        $("input[ name='gxCode']").val(getUrlVariable("gxCode"));
        loadMachine();
        loadData();
        $(document).keyup(function (event) {
            if (event.keyCode == 13) {
                loadData();
            }
        })
    })


    function loadMachine() {
        let gxCode = $("input[name='gxCode']").val();
        $.ajax({
            url: "../Summary/GongXuMachine",
            data: { gxCode: gxCode },
            dataType: "json",
            type: "POST",
            success: function (rsl) {
                if (rsl.result) {
                    var datas = rsl.data;
                    $("select[name='machine'] option:gt(0)").remove();   //先清空除第一个以外全部的option  ，再重新添加
                    for (var i = 0; i < datas.length; i++) {
                        if (datas[i]["cCode"] != "") {
                            $("#machine").append("<option value=\"" + datas[i]["cCode"] + "\" >" + datas[i]["cName"] + "(" + datas[i]["cCode"] + ")" + "</option>");
                        }
                    }
    
                    layui.use('form', function () {
                        var form = layui.form;
                        form.render();
                    });
                }
            }
        });
    }

    layui.use(['laydate'], function () {
        var $ = layui.$;
        var laydate = layui.laydate;
        var nowTime = new Date().valueOf();
        var max = null;
        var start = laydate.render({
            elem: '#sDate',
            trigger: 'click',
            type: 'datetime',
            format: 'yyyy/MM/dd',
            max: nowTime,
            btns: ['clear', 'confirm'],

            done: function (value, date) {
                endMax = end.config.max;
                end.config.min = date; //最大时间为结束时间的开始值
                end.config.min.month = date.month - 1;
            }
        });
        var end = laydate.render({
            elem: '#eDate',
            trigger: 'click',
            type: 'datetime',
            max: 4073558400000,
            format: 'yyyy/MM/dd',
            done: function (value, date) {
                if ($.trim(value) == '') {
                    var curDate = new Date();
                    date = { 'date': curDate.getDate(), 'month': curDate.getMonth() + 1, 'year': curDate.getFullYear() };
                }
                start.config.max = date;//最小时间为开始时间的最大值
                start.config.max.month = date.month - 1;
            }
        })
    })


</script>
